/**
 * Created by zhangqingxi on 2017-03-31.
 */
var modelPath=ROOT_PATH+'/environmental/solidWaste/storageView/';

/**
 * 加载表格
 *
 */

function  loadDataList() {

    $('#dataList').datagrid({
        url:modelPath+'findByParam.shtml',
        queryParams:{
            sort:'d.solidWasteTypeId',
            order:'desc'
        },
        // idField:'id',
        fitColumns:true,
        pagination:true,
        rownumbers:true,
        singleSelect:true,
        sortOrder:true,
        striped:true,
        fit:true,
        columns:[[
            {field:'id',width:10,checkbox:true},
            {field:'solidWasteName',title:'固废名称',width:10},
            {field:'solidWasteTypeName',title:'固废类别',width:10},
            {field:'hazardousWasteCode',title:'危废代码',width:10},
            {field:'storageNumber',title:'历史贮存数量(吨)',width:10,
                formatter:function (value,row,index) {
                    var solidWasteId=row.solidWasteId;
                    var hazardousWasteCodeId=row.hazardousWasteCodeId;
                    var html=value;
                    html+="&nbsp;&nbsp;&nbsp;&nbsp;";
                    html+="<span class='look-storage-tooltip fa fa-tags fa-lg' style='color:green;' onclick='openStorageListView(\""+solidWasteId+"\",\""+hazardousWasteCodeId+"\")' title='查看贮存记录' ></span>";
                    return html;
                }
            },
            {field:'storageDisposeNumber',title:'贮存处理数量(吨)',width:10,
                formatter:function (value,row,index) {
                    var solidWasteId=row.solidWasteId;
                    var hazardousWasteCodeId=row.hazardousWasteCodeId;
                    var html=value;
                    html+="&nbsp;&nbsp;&nbsp;&nbsp;";
                    html+="<span class='look-storage-tooltip fa fa-tags fa-lg' style='color:red;' onclick='openDisposeStorageListView(\""+solidWasteId+"\",\""+hazardousWasteCodeId+"\")' title='查看处理记录' ></span>";
                    return html;
                }
            },
            {field:'currentStorageNumber',title:'剩余数量(吨)',width:10}

        ]],

        toolbar: '#toolbar',
        onLoadSuccess:function () {
            $('.look-storage-tooltip').each(function () {
                $(this).tooltip({
                    position: 'right',
                    content: $(this).title,
                    onShow: function () {
                        $(this).tooltip('tip').css({
                            display:'block'
                        });
                    }
                })

            });
        }

    });
}

function openStorageListView(solidWasteId,hazardousWasteCodeId) {
    openLayer("历史贮存记录",modelPath+"storageList.shtml?solidWasteId="+solidWasteId+"&hazardousWasteCodeId="+hazardousWasteCodeId);
}
function openDisposeStorageListView(solidWasteId,hazardousWasteCodeId) {
    openLayer("贮存处理记录",modelPath+"disposeStorageList.shtml?solidWasteId="+solidWasteId+"&hazardousWasteCodeId="+hazardousWasteCodeId);
}
$(function () {

    loadDataList();

    //查询按钮事件
    initSearchClick('d.solidWasteTypeId');

    //重置参数
    initResetClick();

});